package per.lee.spingboothelper.common.export;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import lombok.Data;
@Data
public abstract class AbsExportSpanModel {

    public Boolean print(HttpServletRequest request, HttpServletResponse response, String fileName) {
        try {
            ExcelData data = new ExcelData();
            data.setName(getSheetName());
            data.setTitles(getTitle());
            data.setRows(getRows());
            ExportExcelUtils.exportExcel(request, response, fileName + ".xls", data);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public abstract List<String> getTitle();

    public abstract List<List<Object>> getRows();

    public abstract String getSheetName();
}
